program C;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

const
  WordsCount = 521196;
var
  f, g, df: TextFile;
  answer: Int64;
  T: Word;
  Words: array[1..WordsCount] of String;
  ss: string;

procedure ReadDictionary;
var
  i: Word;
begin
  AssignFile(df, 'd.txt');
  Reset(df);
  for i := 1 to WordsCount do
    Readln(df, Words[i]);
  CloseFile(df);
end;

procedure ReadData;
begin
  Readln(f, ss);
end;

procedure ProcessData;
var
  i: Word;
begin
//  for i := 1 to WordsCount do
//    if (Pos(Words[i], SS) > 0)
  answer := 0;
end;


procedure OutputVerdict(casenum: Word);
begin
  writeln(g, 'Case #', casenum, ': ', answer);
end;

var
  i: Word;
  s: String;

begin
  try
    ReadDictionary;
    s := ParamStr(1);
    if (s = '') then
       s := 'input.txt';
    AssignFile(f, s);
    Reset(f);
    AssignFile(g, 'output.txt');
    Rewrite(g);
    try
      Readln(f, t);
      for i := 1 to t do begin
        ReadData;
        ProcessData;
        OutputVerdict(i);
      end;
    finally
      CloseFile(f);
      CloseFile(g);
    end;
    writeln('Reading finished');
    Readln;
    { TODO -oUser -cConsole Main : Insert code here }
  except
    on E: Exception do begin
      Writeln(E.ClassName, ': ', E.Message);
      readln;
    end;
  end;
end.
